<template>
  <div class="suppliers">
    <a-page-header
      title="供应商管理"
      sub-title="供应商信息维护"
    >
      <template #extra>
        <a-button type="primary">
          <PlusOutlined />
          新增供应商
        </a-button>
      </template>
    </a-page-header>

    <a-card>
      <a-table
        :columns="columns"
        :data-source="suppliers"
        :pagination="pagination"
      >
        <template #bodyCell="{ column, record }">
          <template v-if="column.key === 'status'">
            <a-tag :color="record.status === 1 ? 'green' : 'red'">
              {{ record.status === 1 ? '合作中' : '已停用' }}
            </a-tag>
          </template>
          <template v-else-if="column.key === 'action'">
            <a-space>
              <a-button type="link" size="small">编辑</a-button>
              <a-button type="link" size="small">查看</a-button>
              <a-button type="link" size="small" danger>删除</a-button>
            </a-space>
          </template>
        </template>
      </a-table>
    </a-card>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'
import { PlusOutlined } from '@ant-design/icons-vue'

const columns = [
  { title: '供应商名称', dataIndex: 'name', key: 'name' },
  { title: '联系人', dataIndex: 'contact', key: 'contact' },
  { title: '联系电话', dataIndex: 'phone', key: 'phone' },
  { title: '地址', dataIndex: 'address', key: 'address' },
  { title: '状态', dataIndex: 'status', key: 'status' },
  { title: '操作', key: 'action', width: 200 },
]

const suppliers = ref([
  {
    id: 1,
    name: '新鲜果业有限公司',
    contact: '张经理',
    phone: '138-0000-0001',
    address: '广东省广州市天河区',
    status: 1
  },
  {
    id: 2,
    name: '优质蔬菜供应商',
    contact: '李经理',
    phone: '138-0000-0002',
    address: '广东省深圳市南山区',
    status: 1
  }
])

const pagination = reactive({
  current: 1,
  pageSize: 10,
  total: 2,
})
</script>

<style scoped>
.suppliers {
  padding: 24px;
}
</style>